﻿using FreesenseSubAIS;
using Sea;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FreesenseSubAIS.Core
{
    public class Algorithm
    {
        private SeaPin  _module;  
        public Algorithm()
        { }
        public SeaPin AlgMod
        {
            get
            {
                if (_module == null)
                    _module = new SeaPin();
                return _module;
            }
            set
            {
                value = _module;
            }
        }
        public Algorithm CloneAlg()
        {
            Algorithm alg = new Algorithm();
            alg.AlgMod.Dispose();
            lock(this)
            {
                alg.AlgMod = this.AlgMod.Clone();
            }
            return alg;
        }
        public int IDisposable()
        {
            try
            {
                this.AlgMod.Dispose();
                return 0;
            }
            catch (Exception ex)
            {
                return 1;
            }
        }
        /// <summary>
        /// 重置参数
        /// </summary>
        /// <param name="type">0-all,1-insp</param>
        /// <param name="spa"></param>
        internal void RestPara(int type, InspParameter  spa)
        {
            if (spa != null)
            {
                lock (this)
                {
                    this.AlgMod.SetPara (spa);
                }
            }
        }
    }
}
